/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.zuq.geocode.route;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author zuq
 */
public class RouteResponse {

    private List<Step> steps;

    public RouteResponse(List<Step> steps) {
        this.steps = steps;
    }

    /**
     * Returns the description of the overall characteristics of the route.
     *
     * @return
     */
    public String getSummary() {

        StringBuilder result = new StringBuilder();

        for (Step step : steps) {
            result.append(step.getDescription()).append("\n");
        }

        return result.toString();
        
    }

    /**
     * Returns the route geometry as a list of coordinates.
     * 
     * @return
     */
    public List<Waypoint> getGeometry() {
        List<Waypoint> result = new ArrayList<Waypoint>();

        for (Step step : steps) {
            result.add(step.getCoordinate());
        }

        return result;
    }

    public double getDuration() {
        // TODO
        return 0.0d;
    }

    public double getDistance() {
        // TODO
        return 0.0d;
    }
    
    /**
     * A piece of information that's usefull in a route description, containing
     * the latitude and longitude of the step and a textual presentation.
     */
    public class Step {

        private Waypoint coord;
        private String description;

        public Step(Waypoint coord, String description) {
            this.coord = coord;
            this.description = description;
        }

        public String getDescription() {
            return description;
        }

        public Waypoint getCoordinate() {
            return coord;
        }
    }

    
}
